
#include <iostream>
#include "fun.h"

int main()
{
    std::cout << "Test cuda Reduce Sum" << std::endl;
    {
    
    int N = 1888*5777;
    hs::raster::RasterData<float> src_datas(N, 1, true);
    for (int i = 0; i < N; ++i) {
        src_datas(i, 0) = 1;
    }

    float res_sum = reduceSum(src_datas);
    printf("Reduction Sum: %10.2f\n", res_sum);
    printf("Reference Sum: %10.2f\n", (float)N);
    std::cout << std::endl;

    }

    std::cout << "Test cuda Reduce Max Index" << std::endl;
    {
    
    int N = 1828*7263;
    hs::raster::RasterData<float> src_datas(N, 1, true);
    for (int i = 0; i < N; ++i) {
        src_datas(i, 0) = (float)(i + 1);
    }

    float max_val;
    int max_id;
    reduceMaxIndex(src_datas, &max_val, &max_id);

    printf("Reduction Max Val: %10.2f\n", max_val);
    printf("Reduction Max Ind: %d\n", max_id);
    
    printf("Reference Max Val: %10.2f\n", (float)N);
    printf("Reference Max Ind: %d\n", N - 1);
    

    }

    std::cout << "Done!" << std::endl;
    return 0;
}
